{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d8bfa2a3",
   "metadata": {},
   "source": [
    "# Introduction\n",
    "This notebook contains Python code snippets that explore and manipulate keystroke data available at [Dataverse URL to come]. Each block of cells is self-contained. All cells are agnostic to which of the two available datasets is used. Simply copy one of the *keystroke.csv*, *students.csv*, and *due.csv* files into this directory."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a3d66db",
   "metadata": {},
   "source": [
    "## Basic keystroke features\n",
    "These cells read <i>keystrokes.csv</i> and print out basic features of the datasets, like participants, assignments, etc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38b00d75",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df = pd.read_csv('keystrokes.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "92a747db",
   "metadata": {},
   "outputs": [],
   "source": [
    "f = df.query('SubjectID == \"Student9\" & AssignmentID == \"Assign9\"')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "074ea6fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "# @@@@@@@@@@@@@@@\n",
      "# CS1400 - 14 Week\n",
      "# Assignment 9\n",
      "\n",
      "import turtle\n",
      "class Face:\n",
      "    def __init__(self):\n",
      "        self.__smile = True\n",
      "        self.__happy = True\n",
      "        self.__darkEyes = True\n",
      "        \n",
      "    def get_smile(self):\n",
      "        return self.__smile\n",
      "\n",
      "    def get_happy(self):\n",
      "        return self.__happy\n",
      "        \n",
      "    def get_eyes(self):\n",
      "        return self.__darkEyes\n",
      "\n",
      "    def draw_face(self):\n",
      "        turtle.clear()\n",
      "        self.__drawHeadhangeMouth()\n",
      "        else:\n",
      "            self.isSmile()\n",
      "\n",
      "\n",
      "        \n",
      "    def isSmile(self):\n",
      "        self.__smile = True\n",
      "        \n",
      "    def isHappy(self):\n",
      "        self.__happy = True\n",
      "        \n",
      "    def isDarkEyes(self):\n",
      "        self.__darkEyes = True\n",
      "        \n",
      "    def changeMouth(self):\n",
      "        self.__smile = False\n",
      "        self.draw_face()\n",
      "        \n",
      "    def changeEmotion(self):\n",
      "        self.__happy = False\n",
      "        self.draw_face()\n",
      "        \n",
      "    def changeEyes(self):\n",
      "        self.__darkEyes = False\n",
      "        self.draw_face()\n",
      "        \n",
      "    def __drawHead(self):\n",
      "        self.__happy\n",
      "\n",
      "            \n",
      "    def __drawEyes(self):\n",
      "        self.__darkEyes\n",
      "\n",
      "    \n",
      "    def __drawMouth(self):\n",
      "        self.__smile\n",
      "\n",
      "            \n",
      "        \n",
      "ll-In>turtl\n",
      "    face = Face()Face()\n",
      "   draw_face()<    smile = face.get_smile\n",
      "    happy = face.get_happy\n",
      "    dark = face.get_eyes\n",
      "Fill-In>w_face()\n",
      "0)\n",
      "            tu    smile = face.get_smile()\n",
      "    happy = face.get_hasmile\n",
      " if smile == False else  frown = face.get_eyes()\n",
      "rthappy  if<happy == False else Fangryn> done:\n",
      "        pblack(\"if dark == False else Fblue\n",
      "        mo<Fill-In>uth = \"frifasmile == True else ce.__smile == True else \"smangr\n",
      "  ifthappy == True else ihapp \"angry\" if Face.__happy ifleyes == True else spy\"<Fill-In>\n",
      "s = \"blue\" if Face.__daprint(\"1Quitmen            if smile:\n",
      "                smile = False\n",
      "            elif not smile:\n",
      "                smile = True\n",
      "\n",
      "            if happy:\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"yellow\")\n",
      "                turtle.goto(0, 0)\n",
      "                turtle.pendown()\n",
      "                turtle.circle(100)\n",
      "                turtle.penup()\n",
      "                turtle.end_fill()\n",
      "            elif not happy:\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"red\")\n",
      "                turtle.goto(0, 0)\n",
      "                turtle.pendown()\n",
      "                turtle.circle(100)\n",
      "                turtle.penup()\n",
      "                turtle.end_fill()\n",
      "                \n",
      "            if dark:\n",
      "                turtle.goto(-25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"black\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "                turtle.goto(25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"black\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "            elif not dark:\n",
      "                turtle.goto(-25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"blue\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "                turtle.goto(25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"blue\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "\n",
      "            if smile:\n",
      "                turtle.penup()\n",
      "                turtle.goto(-65, 50)\n",
      "                turtle.right(45)\n",
      "                turtle.pendown()\n",
      "                turtle.pensize(10)\n",
      "                turtle.circle(90, 100)\n",
      "                turtle.right(55)\n",
      "                turtle.penup()\n",
      "                turtle.pensize(1)\n",
      "            elif not smile:\n",
      "                turtle.goto(70, 50)\n",
      "                turtle.left(130)\n",
      "                turtle.pendown()\n",
      "                turtle.pensize(10)\n",
      "                turtle.circle(90, 100)\n",
      "                turtle.left(130)\n",
      "                turtle.penup()\n",
      "                turtle.pensize(1)\n",
      "            \n",
      "                \n",
      "            \n",
      "Fill-In \n",
      "        elif me            if happy:\n",
      "                happy = False\n",
      "            elif not happy:\n",
      "                happy = True\n",
      "\n",
      "            if happy:\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"yellow\")\n",
      "                turtle.goto(0, 0)\n",
      "                turtle.pendown()\n",
      "                turtle.circle(100)\n",
      "                turtle.penup()\n",
      "                turtle.end_fill()\n",
      "            elif not happy:\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"red\")\n",
      "                turtle.goto(0, 0)\n",
      "                turtle.pendown()\n",
      "                turtle.circle(100)\n",
      "                turtle.penup()\n",
      "                turtle.end_fill()\n",
      "\n",
      "            if dark:\n",
      "                turtle.goto(-25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"black\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "                turtle.goto(25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"black\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "            elif not dark:\n",
      "                turtle.goto(-25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"blue\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "                turtle.goto(25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"blue\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "\n",
      "            if smile:\n",
      "                turtle.penup()\n",
      "                turtle.goto(-65, 50)\n",
      "                turtle.right(45)\n",
      "                turtle.pendown()\n",
      "                turtle.pensize(10)\n",
      "                turtle.circle(90, 100)\n",
      "                turtle.right(55)\n",
      "                turtle.penup()\n",
      "                turtle.pensize(1)\n",
      "            elif not smile:\n",
      "                turtle.goto(70, 50)\n",
      "                turtle.left(130)\n",
      "                turtle.pendown()\n",
      "                turtle.pensize(10)\n",
      "                turtle.circle(90, 100)\n",
      "                turtle.left(130)\n",
      "                turtle.penup()\n",
      "                turtle.pensize(1)\n",
      "Fill-In>\n",
      "        elif me            if dark:\n",
      "                dark = False\n",
      "            elif not dark:\n",
      "                dark = True\n",
      "                \n",
      "            if happy:\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"yellow\")\n",
      "                turtle.goto(0, 0)\n",
      "                turtle.pendown()\n",
      "                turtle.circle(100)\n",
      "                turtle.penup()\n",
      "                turtle.end_fill()\n",
      "            elif not happy:\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"red\")\n",
      "                turtle.goto(0, 0)\n",
      "                turtle.pendown()\n",
      "                turtle.circle(100)\n",
      "                turtle.penup()\n",
      "                turtle.end_fill()\n",
      "\n",
      "            if dark:\n",
      "                turtle.goto(-25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"black\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "                turtle.goto(25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"black\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "            elif not dark:\n",
      "                turtle.goto(-25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"blue\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "                turtle.goto(25, 125)\n",
      "                turtle.pendown()\n",
      "                turtle.begin_fill()\n",
      "                turtle.fillcolor(\"blue\")\n",
      "                turtle.circle(10)\n",
      "                turtle.end_fill()\n",
      "                turtle.penup()\n",
      "\n",
      "            if smile:\n",
      "                turtle.penup()\n",
      "                turtle.goto(-65, 50)\n",
      "                turtle.right(45)\n",
      "                turtle.pendown()\n",
      "                turtle.pensize(10)\n",
      "                turtle.circle(90, 100)\n",
      "                turtle.right(55)\n",
      "                turtle.penup()\n",
      "                turtle.pensize(1)\n",
      "            elif not smile:\n",
      "                turtle.goto(70, 50)\n",
      "                turtle.left(130)\n",
      "                turtle.pendown()\n",
      "                turtle.pensize(10)\n",
      "                turtle.circle(90, 100)\n",
      "                turtle.left(130)\n",
      "                turtle.penup()\n",
      "                turtle.pensize(1)\n",
      "            \n",
      "Fill-In> a selection: \"))\n",
      "  \n",
      "\n",
      "            if happy =   face.isHappy()\n",
      "            else:\n",
      "        otion()\n",
      "\n",
      "           if eyes == True:\n",
      "                face.isDarkEyes()\n",
      "           else:\n",
      "                face.changeEyes()\n",
      "                \n",
      "            if smile == True:\n",
      "                face.isSmile()\n",
      "            else:\n",
      "                face.changeMouth()\n",
      "\n",
      "  \n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'student': 'student9', 'assign': 'assign3', 'nc': 13}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f.CodeStateSection.unique()\n",
    "f = f.query('CodeStateSection == \"task1.py\"')\n",
    "f = f.sort_values('ClientTimestamp')\n",
    "print(reconstruct(f))\n",
    "# f.head()\n",
    "\n",
    "s = \"student9\"\n",
    "a = \"assign3\"\n",
    "nc = 13\n",
    "\n",
    "ret = {'student':s, 'assign':a, 'nc':nc}\n",
    "ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "de78f01e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>EventID</th>\n",
       "      <th>SubjectID</th>\n",
       "      <th>AssignmentID</th>\n",
       "      <th>CodeStateSection</th>\n",
       "      <th>EventType</th>\n",
       "      <th>SourceLocation</th>\n",
       "      <th>EditType</th>\n",
       "      <th>InsertText</th>\n",
       "      <th>DeleteText</th>\n",
       "      <th>X-Metadata</th>\n",
       "      <th>ClientTimestamp</th>\n",
       "      <th>ToolInstances</th>\n",
       "      <th>CodeStateID</th>\n",
       "      <th>X-Compilable</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>Student1</td>\n",
       "      <td>Assign10</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>File.Edit</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Insert</td>\n",
       "      <td># @@@@@@@@@@@@@\\n# CS1400 - MW1\\n# Assignment ??</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1636696834375</td>\n",
       "      <td>PC;PP 1.1.10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>Student1</td>\n",
       "      <td>Assign10</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>File.Edit</td>\n",
       "      <td>46.0</td>\n",
       "      <td>Insert</td>\n",
       "      <td>\\n</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1636696835921</td>\n",
       "      <td>PC;PP 1.1.10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>Student1</td>\n",
       "      <td>Assign10</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>X-Action</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Enter</td>\n",
       "      <td>1636696838793</td>\n",
       "      <td>PC;PP 1.1.10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>Student1</td>\n",
       "      <td>Assign10</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>File.Edit</td>\n",
       "      <td>47.0</td>\n",
       "      <td>Insert</td>\n",
       "      <td>\\n</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1636696839138</td>\n",
       "      <td>PC;PP 1.1.10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>Student1</td>\n",
       "      <td>Assign10</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>X-Action</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Paste</td>\n",
       "      <td>1636696840014</td>\n",
       "      <td>PC;PP 1.1.10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   EventID SubjectID AssignmentID CodeStateSection  EventType  SourceLocation  \\\n",
       "0        0  Student1     Assign10         task1.py  File.Edit             0.0   \n",
       "1        1  Student1     Assign10         task1.py  File.Edit            46.0   \n",
       "2        2  Student1     Assign10         task1.py   X-Action             NaN   \n",
       "3        3  Student1     Assign10         task1.py  File.Edit            47.0   \n",
       "4        4  Student1     Assign10         task1.py   X-Action             NaN   \n",
       "\n",
       "  EditType                                        InsertText DeleteText  \\\n",
       "0   Insert  # @@@@@@@@@@@@@\\n# CS1400 - MW1\\n# Assignment ??        NaN   \n",
       "1   Insert                                                \\n        NaN   \n",
       "2      NaN                                               NaN        NaN   \n",
       "3   Insert                                                \\n        NaN   \n",
       "4      NaN                                               NaN        NaN   \n",
       "\n",
       "  X-Metadata  ClientTimestamp ToolInstances  CodeStateID  X-Compilable  \n",
       "0        NaN    1636696834375  PC;PP 1.1.10          NaN             1  \n",
       "1        NaN    1636696835921  PC;PP 1.1.10          NaN             1  \n",
       "2      Enter    1636696838793  PC;PP 1.1.10          NaN             1  \n",
       "3        NaN    1636696839138  PC;PP 1.1.10          NaN             1  \n",
       "4      Paste    1636696840014  PC;PP 1.1.10          NaN             1  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b41b9222",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17903, 10313\n"
     ]
    }
   ],
   "source": [
    "compilable = len(df[(df['SubjectID'] == 'Student1') & (df['X-Compilable'] == 1)])\n",
    "not_compilable = len(df[(df['SubjectID'] == 'Student1') & (df['X-Compilable'] == 0)])\n",
    "print(f'{compilable}, {not_compilable}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6654a644",
   "metadata": {},
   "outputs": [],
   "source": [
    "# print('Participants:', df.SubjectID.unique())\n",
    "print(f'Number of participants: {len(df.SubjectID.unique())}')\n",
    "print('Assignments:', df.AssignmentID.unique())\n",
    "print('Event types:', df.EventType.unique())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e23dec79",
   "metadata": {},
   "source": [
    "## Reconstruct a submission"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8df4b6e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "# df = pd.read_csv('keystrokes.csv')\n",
    "df = pd.read_csv('~/Downloads/delaney.log')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8e66f966",
   "metadata": {},
   "outputs": [],
   "source": [
    "# # Random\n",
    "# sample = df.sample(1)\n",
    "# subject = sample.SubjectID.values[0]\n",
    "# assignment = sample.AssignmentID.values[0]\n",
    "# file = sample.CodeStateSection.values[0]\n",
    "# Specific\n",
    "subject = 'S219'\n",
    "assignment = 'p6s'\n",
    "file = 'tasks.py'\n",
    "\n",
    "# Filter and handle nan\n",
    "f = df[(df.SubjectID == subject)&(df.AssignmentID == assignment)&\n",
    "       (df.CodeStateSection == file)&(df.EventType == 'File.Edit')]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9d4ec49a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>EventType</th>\n",
       "      <th>InsertText</th>\n",
       "      <th>DeleteText</th>\n",
       "      <th>SourceLocation</th>\n",
       "      <th>ClientTimestamp</th>\n",
       "      <th>CodeStateSection</th>\n",
       "      <th>ToolInstances</th>\n",
       "      <th>EditType</th>\n",
       "      <th>X-Metadata</th>\n",
       "      <th>CodeStateID</th>\n",
       "      <th>X-Compilable</th>\n",
       "      <th>EventID</th>\n",
       "      <th>SubjectID</th>\n",
       "      <th>AssignmentID</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>X-Action</td>\n",
       "      <td>ShowYourWork Init</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1667407325810</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.1.4 for 2021-2022 @t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Init</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>X-Action</td>\n",
       "      <td>ShowYourWork Init</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1667951011641</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.1.4 for 2021-2022 @t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Init</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>File.Edit</td>\n",
       "      <td>#</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1667954225148</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>1.1.4 for 2021-2022 @t1</td>\n",
       "      <td>Insert</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>X-Keystroke</td>\n",
       "      <td>#</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1667954225155</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>1.1.4 for 2021-2022 @t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>#</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>File.Edit</td>\n",
       "      <td>o</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1667954225530</td>\n",
       "      <td>task1.py</td>\n",
       "      <td>1.1.4 for 2021-2022 @t1</td>\n",
       "      <td>Insert</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     EventType         InsertText DeleteText  SourceLocation  ClientTimestamp  \\\n",
       "0     X-Action  ShowYourWork Init        NaN             NaN    1667407325810   \n",
       "1     X-Action  ShowYourWork Init        NaN             NaN    1667951011641   \n",
       "2    File.Edit                  #        NaN             0.0    1667954225148   \n",
       "3  X-Keystroke                  #        NaN             1.0    1667954225155   \n",
       "4    File.Edit                  o        NaN             1.0    1667954225530   \n",
       "\n",
       "  CodeStateSection            ToolInstances EditType X-Metadata  CodeStateID  \\\n",
       "0              NaN  1.1.4 for 2021-2022 @t1      NaN       Init          NaN   \n",
       "1              NaN  1.1.4 for 2021-2022 @t1      NaN       Init          NaN   \n",
       "2         task1.py  1.1.4 for 2021-2022 @t1   Insert        NaN          NaN   \n",
       "3         task1.py  1.1.4 for 2021-2022 @t1      NaN          #          NaN   \n",
       "4         task1.py  1.1.4 for 2021-2022 @t1   Insert        NaN          NaN   \n",
       "\n",
       "   X-Compilable  EventID  SubjectID  AssignmentID  \n",
       "0           NaN      NaN        NaN           NaN  \n",
       "1           NaN      NaN        NaN           NaN  \n",
       "2           NaN      NaN        NaN           NaN  \n",
       "3           NaN      NaN        NaN           NaN  \n",
       "4           NaN      NaN        NaN           NaN  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "2b086c8c",
   "metadata": {},
   "outputs": [],
   "source": [
    "f = df[df.CodeStateSection == 'task1.py']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e9fdcda0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "def reconstruct(df):\n",
    "    s = ''\n",
    "    for _,row in df[df.EventType=='File.Edit'].iterrows():\n",
    "        i = int(row.SourceLocation)\n",
    "        insert = '' if pd.isna(row.InsertText) else row.InsertText\n",
    "        delete = '' if pd.isna(row.DeleteText) else row.DeleteText\n",
    "        s = s[:i] + insert + s[i+len(delete):]\n",
    "    return s\n",
    "\n",
    "s = reconstruct(f)\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "969a367d",
   "metadata": {},
   "source": [
    "## Export keystrokes for a single student and then for a single assignment\n",
    "This is useful when using KeystrokeExplorer, which can't handle the entire *keystrokes.csv* file for Dataset1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2905d4cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df = pd.read_csv('keystrokes.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "caab81b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Random\n",
    "sample = df.sample(1)\n",
    "subject = sample.SubjectID.values[0]\n",
    "assignment = sample.AssignmentID.values[0]\n",
    "# Specific\n",
    "subject = 'S018'\n",
    "assignment = 'p4s'\n",
    "\n",
    "df[df.SubjectID == subject].to_csv(f'test-{subject}.csv', index=False)\n",
    "df[df.AssignmentID == assignment].to_csv(f'test-{assignment}.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9176b84a",
   "metadata": {},
   "source": [
    "## Histogram of the top 20 keystrokes\n",
    "Because the two datasets log keystrokes slightly differently, the code for the two is a little different"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "c2e64620",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "df = pd.read_csv('keystrokes.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f0659ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "if ('X-Keystroke' in set(df.columns)):\n",
    "    # Dataset 1 - each keystroke has its own entry\n",
    "    count = df.loc[~df['X-Keystroke'].isna(), 'X-Keystroke'].value_counts()\n",
    "else:\n",
    "    # Dataset 2 - Each keystroke has its own entry. EditType is X-Keystroke\n",
    "    #   for printable characters and X-Action for meta keys.\n",
    "    mask = (df.EventType == 'X-Keystroke')|((df.EventType == 'X-Action')&(~df['X-Metadata'].isna()))\n",
    "    count = df.loc[mask, 'X-Metadata'].value_counts()\n",
    "    \n",
    "top20 = count.iloc[0:20]\n",
    "sns.barplot(x=top20.index, y=top20.values)\n",
    "plt.xticks(rotation = 90);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8aad02f8",
   "metadata": {},
   "source": [
    "## Estimate how long it took for a random student to complete a random assignment\n",
    "This uses the method given in \"A Practical Model for Student Engagement,\" Edwards et al, SIGCSE 2022."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de5573d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import math\n",
    "import numpy as np\n",
    "\n",
    "df = pd.read_csv('keystrokes.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "796602ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Given a number of minutes x since the last keystroke,\n",
    "# returns the probability that the student was on task.\n",
    "# Uses the model from Edwards et al, SIGCSE 2022.\n",
    "def p(x):\n",
    "    if x < .75:\n",
    "        m = -(1-0.8072438106027864)/.75\n",
    "        return m*x+1\n",
    "    Q = 6604\n",
    "    B = -4.99\n",
    "    M = 0.01\n",
    "    v = 58.32\n",
    "    return 1 / (1+Q*math.e**(-B*(x-M)))**(1/v)\n",
    "\n",
    "# Given a number of minutes x since the last keystroke,\n",
    "# returns whether the student was on task. Uses p(x)\n",
    "# to get the probability and uses that result to take\n",
    "# a percentage of the time between keystrokes.\n",
    "def on_task(x):\n",
    "    if x <= 0 or x > 60:\n",
    "        return 0\n",
    "    return x * p(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "6e91bd1b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8072438106027864"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p(.75)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "521ca818",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(0.0, 1.0),\n",
       " (0.08, 0.9794393397976305),\n",
       " (0.16, 0.9588786795952611),\n",
       " (0.24, 0.9383180193928916),\n",
       " (0.32, 0.9177573591905221),\n",
       " (0.4, 0.8971966989881527),\n",
       " (0.48, 0.8766360387857832),\n",
       " (0.56, 0.8560753785834139),\n",
       " (0.64, 0.8355147183810443),\n",
       " (0.72, 0.814954058178675),\n",
       " (0.8, 0.8037977123066598),\n",
       " (0.88, 0.7983145233691094),\n",
       " (0.96, 0.7928687342417605),\n",
       " (1.04, 0.7874600912719005),\n",
       " (1.12, 0.7820883420450507),\n",
       " (1.2, 0.7767532355407369),\n",
       " (1.28, 0.7714545222323979),\n",
       " (1.36, 0.7661919541500951),\n",
       " (1.44, 0.760965284918469),\n",
       " (1.52, 0.7557742697782235),\n",
       " (1.6, 0.7506186655966661),\n",
       " (1.68, 0.7454982308709784),\n",
       " (1.76, 0.7404127257266705),\n",
       " (1.84, 0.7353619119128512),\n",
       " (1.92, 0.7303455527954018),\n",
       " (2.0, 0.7253634133487785),\n",
       " (2.08, 0.7204152601469265),\n",
       " (2.16, 0.7155008613536242),\n",
       " (2.24, 0.7106199867124776),\n",
       " (2.32, 0.705772407536699),\n",
       " (2.4, 0.7009578966987738),\n",
       " (2.48, 0.6961762286200698),\n",
       " (2.56, 0.6914271792604366),\n",
       " (2.64, 0.6867105261078217),\n",
       " (2.72, 0.682026048167918),\n",
       " (2.8, 0.6773735259538608),\n",
       " (2.88, 0.6727527414759757),\n",
       " (2.96, 0.6681634782315883),\n",
       " (3.04, 0.6636055211948935),\n",
       " (3.12, 0.6590786568068919),\n",
       " (3.2, 0.6545826729653893),\n",
       " (3.28, 0.6501173590150633),\n",
       " (3.36, 0.6456825057375966),\n",
       " (3.44, 0.6412779053418752),\n",
       " (3.52, 0.6369033514542555),\n",
       " (3.6, 0.6325586391088939),\n",
       " (3.68, 0.6282435647381449),\n",
       " (3.76, 0.6239579261630236),\n",
       " (3.84, 0.6197015225837322),\n",
       " (3.92, 0.6154741545702528),\n",
       " (4.0, 0.6112756240530027),\n",
       " (4.08, 0.6071057343135549),\n",
       " (4.16, 0.6029642899754196),\n",
       " (4.24, 0.598851096994892),\n",
       " (4.32, 0.5947659626519591),\n",
       " (4.4, 0.5907086955412707),\n",
       " (4.48, 0.5866791055631706),\n",
       " (4.56, 0.5826770039147906),\n",
       " (4.64, 0.5787022030812037),\n",
       " (4.72, 0.5747545168266384),\n",
       " (4.8, 0.5708337601857525),\n",
       " (4.88, 0.5669397494549674),\n",
       " (4.96, 0.5630723021838602),\n",
       " (5.04, 0.5592312371666154),\n",
       " (5.12, 0.5554163744335345),\n",
       " (5.2, 0.5516275352426042),\n",
       " (5.28, 0.5478645420711207),\n",
       " (5.36, 0.5441272186073728),\n",
       " (5.44, 0.5404153897423809),\n",
       " (5.52, 0.5367288815616919),\n",
       " (5.6, 0.5330675213372311),\n",
       " (5.68, 0.529431137519209),\n",
       " (5.76, 0.5258195597280834),\n",
       " (5.84, 0.5222326187465767),\n",
       " (5.92, 0.518670146511747),\n",
       " (6.0, 0.5151319761071139),\n",
       " (6.08, 0.5116179417548379),\n",
       " (6.16, 0.5081278788079525),\n",
       " (6.24, 0.5046616237426506),\n",
       " (6.32, 0.5012190141506219),\n",
       " (6.4, 0.4977998887314439),\n",
       " (6.48, 0.49440408728502433),\n",
       " (6.56, 0.49103145070409504),\n",
       " (6.64, 0.48768182096675694),\n",
       " (6.72, 0.4843550411290763),\n",
       " (6.8, 0.4810509553177313),\n",
       " (6.88, 0.47776940872270834),\n",
       " (6.96, 0.4745102475900492),\n",
       " (7.04, 0.47127331921464644),\n",
       " (7.12, 0.4680584719330887),\n",
       " (7.2, 0.4648655551165548),\n",
       " (7.28, 0.46169441916375625),\n",
       " (7.36, 0.4585449154939274),\n",
       " (7.44, 0.455416896539864),\n",
       " (7.52, 0.4523102157410094),\n",
       " (7.6, 0.449224727536587),\n",
       " (7.68, 0.44616028735878066),\n",
       " (7.76, 0.4431167516259608),\n",
       " (7.84, 0.44009397773595715),\n",
       " (7.92, 0.43709182405937697)]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import math\n",
    "a = [8*x/100 for x in range(0, 100)]\n",
    "b = [p(x) for x in a]\n",
    "c = list(zip(a,b))\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "103b1785",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Look only at file edits\n",
    "df = df[df.EventType == 'File.Edit']\n",
    "# Compute the elapsed time since the last keystroke\n",
    "df['elapsed'] = df.ClientTimestamp - df.shift(1).ClientTimestamp\n",
    "# Create a unique ID for subject/assignment/file\n",
    "df['ID'] = df.SubjectID + df.AssignmentID + df.CodeStateSection\n",
    "# Any change to a new ID results in 0 elapsed\n",
    "df.loc[df.ID != df.shift(1).ID, 'elapsed'] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4cb8a64",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Get a random assignment\n",
    "sample = df.sample(1)\n",
    "subject = sample.SubjectID.values[0]\n",
    "assignment = sample.AssignmentID.values[0]\n",
    "single = df[(df.SubjectID == subject)&(df.AssignmentID == assignment)]\n",
    "# Estimate time on task. The on_task function expects minutes\n",
    "# (so divide by 60*1000) and we want to print in hours (so divide\n",
    "# again by 60).\n",
    "time_on_task = ((single.elapsed/(60*1000)).apply(on_task)/60).sum()\n",
    "print(f'Student {subject} took {time_on_task:.2f} hours on assignment {assignment}')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c5b992f",
   "metadata": {},
   "source": [
    "## Compare the median number of edit events between students with exam scores above and below 90\n",
    "It turns out that higher performing students on the exams use more edits to complete their assignments. But maybe they're just more likely to complete their assignments..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2070e2d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "\n",
    "df = pd.read_csv('keystrokes.csv')\n",
    "students = pd.read_csv('students.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "a19c625e",
   "metadata": {},
   "outputs": [],
   "source": [
    "above = students[students.exam1 >= 90].SubjectID.unique()\n",
    "below = students[students.exam1 < 90].SubjectID.unique()\n",
    "# Choose the first assignment\n",
    "assignment = df.AssignmentID.values[0]\n",
    "count_above = df.loc[df.SubjectID.isin(above) & (df.AssignmentID == assignment), 'SubjectID'].value_counts()\n",
    "count_below = df.loc[df.SubjectID.isin(below) & (df.AssignmentID == assignment), 'SubjectID'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "ec2e8d39",
   "metadata": {},
   "outputs": [],
   "source": [
    "count_above = count_above.to_frame()\n",
    "count_above['Group'] = 'above'\n",
    "count_below = count_below.to_frame()\n",
    "count_below['Group'] = 'below'\n",
    "count = count_above.append(count_below).reset_index()\n",
    "count.columns = ['SubjectID', 'Count', 'Group']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f822584b",
   "metadata": {},
   "outputs": [],
   "source": [
    "display(f'mean above: {count[count.Group==\"above\"].Count.mean()}')\n",
    "display(f'mean below: {count[count.Group==\"below\"].Count.mean()}')\n",
    "sns.displot(x='Count', hue='Group', data=count, kind='kde')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "018d5484",
   "metadata": {},
   "source": [
    "## Scatterplot of number of keystrokes vs score on an assignment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "6f276c14",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import scipy.stats\n",
    "\n",
    "df = pd.read_csv('keystrokes.csv')\n",
    "students = pd.read_csv('students.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5efcabf8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# No assignment in particular\n",
    "assignment = df.AssignmentID.values[0]\n",
    "# A specific assignment\n",
    "assignment = 'p6s'\n",
    "\n",
    "count = df.loc[df.AssignmentID == assignment, 'SubjectID'].value_counts()\n",
    "count = count.to_frame().reset_index()\n",
    "count.columns = ['SubjectID', 'NumKeystrokes']\n",
    "count = count.merge(students, on='SubjectID')\n",
    "\n",
    "raw_assignment = assignment\n",
    "if 'X-RawAssignmentID' in df.columns:\n",
    "    # Dataset 1\n",
    "    raw_assignment = assignment[:-1]\n",
    "    count = count[count.Group == ('Fall' if assignment[-1] == 'f' else 'Spring')]\n",
    "count = count[['SubjectID', 'NumKeystrokes', raw_assignment]]\n",
    "count.columns = ['SubjectID', 'NumKeystrokes', 'Score']\n",
    "count = count.dropna()\n",
    "# count\n",
    "\n",
    "sns.scatterplot(x='NumKeystrokes', y='Score', data=count)\n",
    "display(f'Pearson r correlation: {scipy.stats.pearsonr(count.NumKeystrokes, count.Score)}')\n",
    "\n",
    "count[count.Score == 0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "37fb1153",
   "metadata": {},
   "source": [
    "## Scatterplot of final submission size vs score on an assignment\n",
    "We could reconstruct each file and count the number of characters but a faster way is to get the length of each text insert and deletion and sum those."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5480c5f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import scipy.stats\n",
    "\n",
    "df = pd.read_csv('keystrokes.csv')\n",
    "students = pd.read_csv('students.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "id": "2e5ee741",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Pearson r correlation: (0.33776040207184294, 8.679673761910991e-08)'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SubjectID</th>\n",
       "      <th>SubSize</th>\n",
       "      <th>Score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>108</th>\n",
       "      <td>S219</td>\n",
       "      <td>2527.0</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>220</th>\n",
       "      <td>S439</td>\n",
       "      <td>2085.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>254</th>\n",
       "      <td>S500</td>\n",
       "      <td>2100.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    SubjectID  SubSize  Score\n",
       "108      S219   2527.0   20.0\n",
       "220      S439   2085.0    0.0\n",
       "254      S500   2100.0    0.0"
      ]
     },
     "execution_count": 175,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAsy0lEQVR4nO3df5xcdX3v8ddnZnd2s7vJJtksm5gQlsgCGkCMKz+qWJtURIqAXB8gtQ9/FJrbXjHx0qqoVNRS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GfCgUREfGpUBAREZ8KBRER8alQEBERnwoFERHx/X/MQI3gv8bSXwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# No assignment in particular\n",
    "assignment = df.AssignmentID.values[0]\n",
    "# A specific assignment\n",
    "assignment = 'p6s'\n",
    "\n",
    "mask = (df.AssignmentID == assignment)&(df.EventType == 'File.Edit')\n",
    "df.loc[mask,'Diff'] = df[mask].InsertText.fillna('').str.len() - df[mask].DeleteText.fillna('').str.len()\n",
    "count = df[mask].groupby('SubjectID').agg({'Diff':'sum'}).reset_index()\n",
    "count.columns = ['SubjectID','SubSize']\n",
    "# count.head()\n",
    "\n",
    "count = count.merge(students, on='SubjectID')\n",
    "\n",
    "raw_assignment = assignment\n",
    "if 'X-RawAssignmentID' in df.columns:\n",
    "    # Dataset 1\n",
    "    raw_assignment = assignment[:-1]\n",
    "    count = count[count.Group == ('Fall' if assignment[-1] == 'f' else 'Spring')]\n",
    "count = count[['SubjectID', 'SubSize', raw_assignment]]\n",
    "count.columns = ['SubjectID', 'SubSize', 'Score']\n",
    "count = count.dropna()\n",
    "count\n",
    "\n",
    "sns.scatterplot(x='SubSize', y='Score', data=count)\n",
    "display(f'Pearson r correlation: {scipy.stats.pearsonr(count.SubSize, count.Score)}')\n",
    "\n",
    "count[(count.Score < 30)&(count.SubSize > 2000)]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
